<?php
/**
 * Created by JetBrains PhpStorm.
 * User: akrug
 * Date: 31.05.12
 * Time: 12:20
 * To change this template use File | Settings | File Templates.
 */

include_once('UcsMvc/AbstractForm.php');

class Form_User_User extends UcsMvc_AbstractForm
{

    public function init(){
        // uebersetzen der Meldungen
		//$translate = new Zend_Translate('array', 'formMessages.php', 'de');
        //Zend_Validate_Abstract::setDefaultTranslator($translate);

        $this->setAttrib('class', 'userindex');
        $this->setAction('');
		$this->setMethod('post');
        $this->setName('User');

        /**
         * email des neuen benutzers
         */
		$element = new Zend_Form_Element_Text('fe_user_email');
        $element
            ->setLabel($this->_translator->translate('E-Mail Adresse', $this->_language))
            ->setRequired(true)
            ->addValidator('EmailAddress', true)
            ->addErrorMessage($this->_translator->translate('E-Mail Adresse ist ungültig', $this->_language));
        $this->addElement($element);

        /**
         * vorname des benutzers
         */
		$element = new Zend_Form_Element_Text('fe_user_firstname');
        $element
            ->setLabel($this->_translator->translate('Vorname', $this->_language))
            ->setRequired(true)
            ->addValidator('StringLength', true, array('min' => 1, 'max' => 150))
            ->addErrorMessage($this->_translator->translate('Vorname ist ungültig', $this->_language));
        $this->addElement($element);

        /**
         * nachmname des benutzers
         */
		$element = new Zend_Form_Element_Text('fe_user_lastname');
        $element
            ->setLabel($this->_translator->translate('Nachname', $this->_language))
            ->setRequired(true)
            ->addValidator('StringLength', true, array('min' => 1, 'max' => 150))
            ->addErrorMessage($this->_translator->translate('Nachname ist ungültig', $this->_language));
        $this->addElement($element);

        $element = new Zend_Form_Element_Password('fe_user_password');
        $element
            ->setLabel($this->_translator->translate('Passwort', $this->_language))
            ->addValidator('stringLength', true, 8)
            ->addValidator('Regex',true, array('pattern' => "/^[A-Za-z0-9[:punct:]]{8,}$/"))
            ->addValidator('Regex',true, array('pattern' => "/[0-9]+/"))
            ->addValidator('Regex',true, array('pattern' => "/[A-Za-z]+/"))
            ->addValidator('Regex',true, array('pattern' => "/[[:punct:]]+/"))
            ->addErrorMessage($this->_translator->translate('Passwort ist ungültig', $this->_language));
                 //->setDecorators($this->elementDecorators);
        $this->addElement($element);

        $element = new Zend_Form_Element_Password('passwordConfirm');
        $element
            ->setLabel($this->_translator->translate('Passwort bestätigen', $this->_language))
            ->addValidator('identical', true, array('token' => 'fe_user_password'))
            ->addErrorMessage($this->_translator->translate('Passwortbestätigung ist ungültig', $this->_language));
                        //->setDecorators($this->elementDecorators);
        $this->addElement($element);

        $this->prepareDecorators();
    }

}
